<template>
  <div id="app">
    <Topbar :key="topbarkeyvalue"></Topbar>
    <Header></Header>
    <router-view/>
    <Footer></Footer>
    <Login v-show="isShowLoginModal"></Login>
    <transition name="fade">
      <Toast v-show="isshowtoast"></Toast>
  </transition>
  </div>
</template>
<script>
import Topbar from '@/components/Topbar'
import Header from '@/components/Header'
import Footer from '@/components/Footer'
import Login from '@/components/Login'
import Toast from '@/components/Toast'
import {mapState} from 'vuex'

export default {
  data() {
    return {
      topbarkeyvalue:1
    }
  },
  watch:{
    "$route.path":{
      handler(newVal,oldVal){
        if(newVal!==oldVal){
          // console.log('组件重载this',this);
          this.topbarkeyvalue++
        }
      }
    }
  },
  computed: {
    ...mapState({
      isShowLoginModal:state=>state.showLoginModal.isShowLoginModal,
      isshowtoast:state=>state.showtoast.isshowtoast
    })
  },
  components:{
    Topbar,Header,Footer,Login,Toast
  }
}
</script>
<style lang="scss" scoped>
.fade-enter,.fade-leave-to{
  opacity: 0;
}
.fade-enter-active,.fade-leave-active{
  transition: all .5s linear;
}
.fade-enter-to,.fade-leave{
  opacity: 1;
}
#app {
  font-family: Avenir, Helvetica, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-align: center;
  color: #2c3e50;
}

nav {
  padding: 30px;

  a {
    font-weight: bold;
    color: #2c3e50;

    &.router-link-exact-active {
      color: #42b983;
    }
  }
}
</style>
